/**
 * 旋转数组
 * https://leetcode-cn.com/problems/rotate-array/
 * @param {number[]} nums
 * @param {number} k
 * @return {void} Do not return anything, modify nums in-place instead.
 */
 var rotate = function(nums, k) {
  
      let len = nums.length
      let offset = k%len
      if(!offset || len === offset){
        return nums
    }
      let leftArr = nums.slice(- offset)
      leftArr.push(...nums.slice(0,len-offset))
      leftArr.map((val,i)=>{
        nums[i] = val
      })
};


let nums = [1,2,3,4,5,6,7],k = 3

rotate(nums,k)
console.log(nums)

//================v1要点总结===============
/**
 * 1.该种方法借用了数组的方法，算是最笨的方法，并且空间复杂度为O(2n)，不推荐
 */